<%
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", -1); //prevents caching at the proxy server
%>
<%@page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*"%>
<%@ include file="Connections/conDB.jsp" %>
<% int validaSession = 2; %>
<%@ include file="Connections/session.jsp" %>

<%
String parColumnas = request.getParameter("columnas");
//out.print(parColumnas+"<br>");
String columna = "";
int inicio = 0;
int fin = 1;
String colValor = "";

Driver DriverRs = (Driver)Class.forName(MM_conDB_DRIVER).newInstance();
Connection ConnRs = DriverManager.getConnection(MM_conDB_STRING,MM_conDB_USERNAME,MM_conDB_PASSWORD);
String query ="";
PreparedStatement StatementRs =null;

if (parColumnas!=null && !parColumnas.equals("") && parColumnas.length()>1) {
	while (fin > 0 && fin < parColumnas.length()) {
		//out.print(inicio+"--ini<br>");
		fin = parColumnas.indexOf("|",inicio);
		//out.print(fin+"--fin<br>");
		if (fin > 0) {
			columna = parColumnas.substring(inicio,fin);
			//out.print(columna+"<br>");

			colValor = request.getParameter(columna+"Cod");
			if (columna.equals("grabar_informix")) {
				colValor = (colValor!=null && !colValor.equals(""))?colValor:"0";
				//out.print(colValor+"<br>");
			} else {
				colValor = (colValor!=null && !colValor.equals(""))?colValor:"-1";
			}
			
			//if (columna.equals("server_host") || columna.equals("email_CIMA")) {
			if (columna.compareToIgnoreCase("server_host") == 0 || columna.compareToIgnoreCase("email_CIMA") == 0 || columna.compareToIgnoreCase("inf_prefijo") == 0 ||
				columna.compareToIgnoreCase("inf_tipo_mov") == 0 || columna.compareToIgnoreCase("inf_aplicacion") == 0 || columna.compareToIgnoreCase("inf_unidad") == 0 ||
				columna.compareToIgnoreCase("inf_compania") == 0 || columna.compareToIgnoreCase("codtransTFM") == 0 || columna.compareToIgnoreCase("grabar_informix") == 0 ||
				columna.compareToIgnoreCase("nolineas_print") == 0 || columna.compareToIgnoreCase("session_corta") == 0 || columna.compareToIgnoreCase("session_larga") == 0 ||
				columna.compareToIgnoreCase("capac_unidad") == 0 || columna.compareToIgnoreCase("bodega_virtual") == 0 ||
				columna.compareToIgnoreCase("cod_planta") == 0 || columna.compareToIgnoreCase("cod_puerto") == 0 || columna.compareToIgnoreCase("user_mail") == 0 || columna.compareToIgnoreCase("pass_mail") == 0  || columna.compareToIgnoreCase("factor_bushel") == 0 || columna.compareToIgnoreCase("factor_humedad") == 0  ) {

				query = "UPDATE parametro SET "+
						""+columna+" = '"+colValor+"'";
			} else {
				query = "UPDATE parametro SET "+
						""+columna+" = "+colValor+"";
			}
			//out.print(query+"<br>");
			StatementRs = ConnRs.prepareStatement(query);
		    StatementRs.executeUpdate();

		} // fin if (fin > 0)
		inicio = fin+1;

	} // fin while (fin < parColumnas.length())
	
}
	out.print("<script>");
	out.print("window.location='parametros_lista.jsp'");
	out.print("</script>");

ConnRs.close();

%>
<html>
<head>
<title>CIMA v2 - Guardar Parametros</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">

</body>
<HEAD>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</HEAD>
</html>
